
#include "common.h"
#include "sst_table.h"
#include "sst_id.h"
#include <iostream>
#include "mem.h"
#include <assert.h>
#include <vector>

int main() {
  VirtualR::SkipList *mem = new VirtualR::SkipList();
  std::string temp = "ys_test";
  for (int i = 0; i < 20; i++) {
    mem->put(temp + std::to_string(i), "hhh" + std::to_string(i));
  }
  mem->put("zys", "fdasfsd");
  mem->put("a", "fds");
  mem->put("b", "fdsa");

  VirtualR::SSTableID id_("./data", 1);
  VirtualR::SSTable *table = new VirtualR::SSTable(mem, id_);
  
  std::vector<VirtualR::Entry_t> entries = table->load();
  for (VirtualR::Entry_t entry : entries) {
    std::cout << GREEN << entry.key << ":" << entry.value << END << std::endl;
  }
  
  std::cout << GREEN << "lower: " << table->lower() << " higher: " << table->higher() << END << std::endl;
  delete mem;
  assert(table->lower() == "a");
  assert(table->higher() == "zys");
}
